;;;****************************************************************************
(DEFUN c:lispfunslist ()
  (IF check_for_doslib NIL (LOAD "check_for_doslib" "\nFile CHECK_FOR_DOSLIB.LSP not loaded! "))
  (check_for_doslib)
  (SETQ file_cnt 0)
  (SETQ done_this_file NIL)
  (SETQ myfuns_lst NIL)
  (SETQ sellisp_files
         (dos_getfilem
           "Select Autolisp Files"
           "L:/Util/Lsp/"
           "Autolisp files (*.lsp)|*.lsp||"
         ) ;_ end of dos_getfilem
  ) ;_ end of SETQ
  (SETQ gpd_path (STRCAT (NTH 0 sellisp_files)(NTH 1 sellisp_files))
        gpd_split_path (DOS_SPLITPATH gpd_path)
  )
  (IF gpd_path
    (PROGN
          (SETQ dclfile_lst NIL)
;;;          (SETQ subout (OPEN (STRCAT (NTH 0 gpd_split_path)(NTH 1 gpd_split_path) "gpdgnfuns.txt") "w"))
          (SETQ file_lst (CDR sellisp_files))
;;;          (PRINC (CHR 40) subout)
;;;          (PRINC)
          (SETQ this_defun_list NIL
                defunslist NIL
          )
          (IF ukword NIL (LOAD "ukword" "\nFile UKWORD.LSP not loaded! "))
          (SETQ print_funs_list (ukword 1 "All Commands No" "Print functions to text screen? [All/Commands/No]" (IF print_funs_list print_funs_list "No")))
          (FOREACH n file_lst
            (IF this_defun_list
              (PROGN
                (SETQ this_defun_list (acad_strlsort this_defun_list))
                (SETQ defunslist (APPEND defunslist (LIST (CONS prev_n_file this_defun_list))))
                (SETQ this_defun_list NIL)
              )
            )
            (SETQ prev_n_file n)
            (PRINC)
;;;            (IF done_this_file
;;;              (PROGN (PRINC (CHR 41) subout)
;;;                     (SETQ back_spaces ""
;;;                           front_spaces ""
;;;                     ) ;_ end of SETQ
;;;                     (REPEAT (+ (STRLEN this_file) 0) (SETQ back_spaces (STRCAT back_spaces "\010")))
;;;                     (REPEAT (+ (STRLEN this_file) 0) (SETQ front_spaces (STRCAT front_spaces " ")))
;;;                     (PRINC back_spaces)
;;;                     (PRINC front_spaces)
;;;                     (PRINC back_spaces)
;;;                     (PRINC)
;;;              ) ;_ end of PROGN
;;;            ) ;_ end of IF
            (SETQ this_file n
                  done_this_file NIL
            ) ;_ end of SETQ
              (PROGN
                (SETQ cur_file (OPEN (STRCAT (NTH 0 gpd_split_path)(NTH 1 gpd_split_path) n) "r"))
                (WHILE (SETQ rd_line (READ-LINE cur_file))
                  (IF (OR (AND (WCMATCH (STRCASE rd_line) "*DEFUN*") (NOT (WCMATCH (STRCASE rd_line) "*;*DEFUN*")))
                          (AND (WCMATCH (STRCASE rd_line) "*DEFUN*") (WCMATCH (STRCASE rd_line) "*DEFUN*;*DEFUN*"))
                          (AND (WCMATCH (STRCASE rd_line) "*(LOAD_DIALOG*")
                               (NOT (WCMATCH (STRCASE rd_line) "*;*(LOAD_DIALOG*"))
                          ) ;_ end of AND
                      ) ;_ end of OR
                    (PROGN
                      (SETQ caprd_line (STRCASE rd_line))
                      (SETQ rd_tokens (DOS_STRTOKENS rd_line (STRCAT " \t " (CHR 41))))
                      (COND ((WCMATCH caprd_line (STRCAT "*" (CHR 40) "DEFUN-Q*"))
                             (SETQ this_member
                                    (MEMBER (STRCAT (CHR 40) "DEFUN-Q")
                                            (DOS_STRTOKENS caprd_line (STRCAT " \t " (CHR 41)))
                                    ) ;_ end of MEMBER
                             ) ;_ end of SETQ
                            )
                            ((WCMATCH caprd_line (STRCAT "*" (CHR 40) "DEFUN*"))
                             (SETQ this_member
                                    (MEMBER (STRCAT (CHR 40) "DEFUN")
                                            (DOS_STRTOKENS caprd_line (STRCAT " \t " (CHR 41)))
                                    ) ;_ end of MEMBER
                             ) ;_ end of SETQ
                            )
                            ((WCMATCH caprd_line (STRCAT "*" (CHR 40) "LOAD_DIALOG*"))
                             (SETQ this_member
                                    (MEMBER (STRCAT (CHR 40) "LOAD_DIALOG")
                                            (DOS_STRTOKENS caprd_line (STRCAT " \t " (CHR 41)))
                                    ) ;_ end of MEMBER
                             ) ;_ end of SETQ
                            )
                            (T (SETQ this_member NIL))
                      ) ;_ end of COND
                      (IF this_member
                        (PROGN
                          (SETQ this_defun_# (- (LENGTH rd_tokens) (LENGTH this_member))
                                this_defun   (NTH this_defun_# rd_tokens)
                          ) ;_ end of SETQ
                          (WHILE (WCMATCH this_defun " *") (SETQ this_defun (SUBSTR this_defun 2)))
                          (WHILE (WCMATCH this_defun "* ")
                            (SETQ this_defun (SUBSTR this_defun 1 (1- (STRLEN this_defun))))
                          ) ;_ end of WHILE
                          (IF (AND (> (LENGTH this_member) 1)
                                   (SETQ this_defun_name (NTH (1+ this_defun_#) rd_tokens))
                                   (WCMATCH this_defun_name "*@*")
                              ) ;_ end of AND
                            NIL
                            (PROGN
                              (IF (NOT (WCMATCH this_defun_name "*@*"))
                                (SETQ this_defun_name NIL)
                              ) ;_ end of IF
                              (WHILE
                                (AND (NOT this_defun_name) (SETQ rd_line (READ-LINE cur_file)) (WCMATCH rd_line "*@*"))
                                 (SETQ this_defun_name (CAR (DOS_STRTOKENS rd_line (STRCAT " \t " (CHR 41)))))
                              ) ;_ end of WHILE
                            ) ;_ end of PROGN
                          ) ;_ end of IF
                          (IF (AND this_defun
                                   this_defun_name
                                   (WCMATCH this_defun_name "*@*")
                                   (NOT (WCMATCH (STRCASE this_defun) "*LOAD_DIALOG*"))
                              ) ;_ end of AND
                            (PROGN
                                   (WHILE (WCMATCH this_defun_name "\"*") (SETQ this_defun_name (SUBSTR this_defun_name 2)))
                                   (WHILE (WCMATCH this_defun_name "*\"")
                                     (SETQ this_defun_name (SUBSTR this_defun_name 1 (1- (STRLEN this_defun_name))))
                                   ) ;_ end of WHILE
                                   (IF done_this_file
;;;                                     (PROGN (PRINC " \"" subout)
;;;                                            (PRINC this_defun_name subout)
;;;                                            (PRINC "\"" subout)
;;;                                     )
                                     NIL
;;;                                     (PROGN (PRINC (STRCAT (CHR 40) "\"") subout)
;;;                                            (PRINC this_file subout)
;;;                                            (PRINC "\" \"" subout)
;;;                                            (PRINC this_defun_name subout)
;;;                                            (PRINC "\"" subout)
;;;                                            (PRINC)
                                            (SETQ done_this_file T)
;;;                                     ) ;_ end of PROGN
                                   ) ;_ end of IF
                              (SETQ this_defun_list (APPEND this_defun_list (LIST this_defun_name)))
                            ) ;_ end of PROGN
                            (IF (AND this_defun this_defun_name (WCMATCH (STRCASE this_defun) "*LOAD_DIALOG*"))
                              (PROGN (COND ((WCMATCH this_defun_name "\"*\"")
                                            (SETQ dcl_name (SUBSTR this_defun_name 2 (- (STRLEN this_defun_name) 2)))
                                           )
                                           ((WCMATCH this_defun_name "\"*") (SETQ dcl_name (SUBSTR this_defun_name 2)))
                                           ((WCMATCH this_defun_name "*\"")
                                            (SETQ dcl_name (SUBSTR this_defun_name 1 (1- (STRLEN this_defun_name))))
                                           )
                                     ) ;_ end of COND
                                     (SETQ dclfile_name (STRCAT "\"" dcl_name ".dcl\"")
                                           dcl_name     (STRCAT "\"" dcl_name "\"")
                                     ) ;_ end of SETQ
                                     (IF dclfile_lst
                                       (IF (ASSOC dclfile_name dclfile_lst)
                                         NIL
                                         (PROGN (SETQ dclfile_lst
                                                       (APPEND dclfile_lst (LIST (LIST dclfile_name dcl_name))) ; _ end
                                                                                                                ; of
                                                                                                                ; APPEND
                                                ) ;_ end of SETQ
                                         ) ;_ end of PROGN
                                       ) ;_ end of IF
                                       (SETQ dclfile_lst (LIST (LIST dclfile_name dcl_name)))
                                     ) ;_ end of IF
                              ) ;_ end of PROGN
                            ) ;_ end of IF
                          ) ;_ end of IF
                        ) ;_ end of PROGN
                      ) ;_ end of IF
                    ) ;_ end of PROGN
                  ) ;_ end of IF
                ) ;_ end of WHILE
                (CLOSE cur_file)
              ) ;_ end of PROGN
          ) ;_ end of FOREACH
          (IF this_defun_list (SETQ this_defun_list (acad_strlsort this_defun_list)))
          (SETQ defunslist (APPEND defunslist (LIST (CONS prev_n_file this_defun_list))))
          (IF (EQ print_funs_list "No")
            NIL
            (FOREACH o defunslist
              (PRINC "\n\n")
              (PRINC (CAR o))
              (COND
                ((EQ print_funs_list "All")
                  (PRINC "\nCommands & Functions defined: "))
                ((EQ print_funs_list "Commands")
                  (PRINC "\nCommands defined: "))
              )
              (IF (OR
                    (EQ print_funs_list "All")
                    (EQ print_funs_list "Commands")
                  )
                (FOREACH p (CDR o)
                  (IF (OR
                        (EQ print_funs_list "All")
                        (AND
                          (EQ print_funs_list "Commands")
                          (WCMATCH (STRCASE p) "C:*")
                        )
                      )
                    (PROGN
                      (PRINC "\n   ")
                      (PRINC p)
                      (PRINC)
                    )
                  )
                )
              )
            )
          )
;;;          (IF done_this_file
;;;            (PROGN
;;;              (IF dclfile_lst
;;;                (PROGN (PRINC (CHR 41) subout) (FOREACH n dclfile_lst (PRINC n subout)) (PRINC (CHR 41) subout))
;;;                (PRINC (STRCAT (CHR 41) (CHR 41)) subout)
;;;              ) ;_ end of IF
;;;            ) ;_ end of PROGN
;;;          ) ;_ end of IF
;;;          (CLOSE subout)
    ) ;_ end of PROGN
  ) ;_ end of IF
  (PRINC)
) ;_ end of DEFUN
